////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Filename:    RedSandsGuts.h                                               //
//  Developer:   Tommy Riddle                                                 //
//  Create date: 10/07/2005                                                   //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Description: This is the class declaration for the slot gut of the        //
//               Australian Slot machine called Red Sands.                    //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//        Copyright (c) 2005 - Realtime Gaming.  All rights reserved.         //
////////////////////////////////////////////////////////////////////////////////

#if !defined(__REDSANDSGUTS_H__)
#define __REDSANDSGUTS_H__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "slotguts.h"
#include "getrand.h"

class RedSandsGuts : public SlotGuts
{
public:
	RedSandsGuts();

	virtual ~RedSandsGuts();

private:
	// Shared enums between client and server
	#include "RedSandsCommon.h"

	// Helpful lookup arrays.
	static SpinResult m_aLineWinSpinResults[NUM_VALID_ICONS][6];

	static SpinResult m_aScatterWinSpinResults[6];

	// Inline functions to use with the arrays that also do
	// bounds checking.
	static SpinResult lookupLineWinSpinResult( uint8 nIconType, uint8 nCount )
	{
		if ( nIconType < NUM_VALID_ICONS && nCount < 6 )
		{
			return m_aLineWinSpinResults[ nIconType ][ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

	static SpinResult lookupScatterWinSpinResult( uint8 nCount )
	{
		if ( nCount < 6 )
		{
			return m_aScatterWinSpinResults[ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

	enum EvalType
	{
		etLeftToRight,
		etRightToLeft,
		etAny
	};

	// Helper functions for classifyStops.
	SpinResult getKangarooLineWinResult( uint8* stops ) const;

	SpinResult getLineWinResultWithPossibleSubstitution(
		uint8* stops, uint8 testIcon, bool& bSubstitution ) const;

	bool doesKangarooLineWinPayMore( SpinResult srKangaroo, SpinResult srOther,
		bool bSubstitution ) const;

	void tryForJackpot( SlotSpin* spin );
	
	SpinResult getScatterWinResult( SlotSpin* spin, EvalType et, int32& scatterPositions, bool& bSubstitution ) const;

	void evaluateScatterWin( SlotSpin* spin, SpinResult srScatterResult, int32 scatterPositions, bool bSubstitution );

	void evaluateFeatureTrigger( SlotSpin* spin, SpinResult srScatterResult, int32 scatterPositions );

	void resetReelHoldStops();
	int32 getReelHoldStop( uint8 nReel );
	void setReelHoldStop( uint8 nReel, int32 nStop );

public:
	virtual void classifyStops( SpinLine* spinline, uint8* stops, uint8 bet, uint8 line,
		uint8& rtnresult, uint8& multiplier );

	virtual void classifyScatters( SlotSpin *spin );

    virtual bool8 isValidGuts();

protected:
	// Override of the framework function.
	virtual void preSpinClassifyResults( SlotSpin *spin );
	virtual void Debug_SetLoserStops( uint8* pStops );

	virtual void initDebugFunctionMap();

	enum
	{
		EVT_DEBUG_FUNCTION_RESPINS_1 = BEGIN_SUB_MODIFY_NEXT_RESULT_FUNCTION_RANGE,
		EVT_DEBUG_FUNCTION_RESPINS_2,
		EVT_DEBUG_FUNCTION_RESPINS_3,
		EVT_DEBUG_FUNCTION_RESPINS_4,
		EVT_DEBUG_FUNCTION_RESPINS_5,
		EVT_DEBUG_FUNCTION_RESPINS_6,
		EVT_DEBUG_FUNCTION_RESPINS_7,
		EVT_DEBUG_FUNCTION_RESPINS_8,
		EVT_DEBUG_FUNCTION_RESPINS_9,
		EVT_DEBUG_FUNCTION_RESPINS_10
	};

	void DebugFeature_Respins1(SlotSpin *spin );
	void DebugFeature_Respins2(SlotSpin *spin );
	void DebugFeature_Respins3(SlotSpin *spin );
	void DebugFeature_Respins4(SlotSpin *spin );
	void DebugFeature_Respins5(SlotSpin *spin );
	void DebugFeature_Respins6(SlotSpin *spin );
	void DebugFeature_Respins7(SlotSpin *spin );
	void DebugFeature_Respins8(SlotSpin *spin );
	void DebugFeature_Respins9(SlotSpin *spin );
	void DebugFeature_Respins10(SlotSpin *spin );

	static int g_nDebugRespins;
};

#endif // !defined(__REDSANDSGUTS_H__)
